package com.weixiaodong.ModelDesign.交给子类.TemplateMethod模式.模版方法实例;

@SuppressWarnings("all")
public class StringDisplace extends AbstractDisplace {

    private String content;

    public StringDisplace(String content) {
        this.content = content;
    }

    @Override
    public void open() {
        System.out.println("打开画笔");
    }

    @Override
    public void print() {
        System.out.println(this.content);
    }

    @Override
    public void close() {
        System.out.println("关闭画笔");
    }

    public void printLine() { // 子类自身的方法
        this.open();
        System.out.println(this.content);
        this.close();
    }


    public static void main(String[] args) {
        StringDisplace stringDisplace = new StringDisplace("hello world");
        stringDisplace.displace(); // 隐藏了具体的展示过程，只对外暴露一个dispalce接口
        stringDisplace.printLine();
    }
}
